#pragma once
#include "ALBaseSaliency.h"

#define COV_MAT_REG 50.0f

static const int CL_RGB = 1;
static const int CL_Lab = 2;
static const int CL_Luv = 4;

static cv::RNG BMS_RNG;

class CALSBMS : public CALBaseSaliency
{
public:
	CALSBMS();
	CALSBMS(CALStepItem* pStepItem);
	~CALSBMS();

public:
	//https://github.com/abin24/Saliency-detection-toolbox
	virtual void test();
	virtual void convert();
	virtual void convert(const Mat &src, Mat &dst);

public:
	void calculateSaliencyMap(Mat *src, Mat * dst, int sample_step = 3, int dw1 = 3, bool nm = 1, bool hb = 0, int colorSpace = 2, bool whitening = 1, float max_dimension = -1);

	void BMSinit(const cv::Mat& src, int dw1, bool nm, bool hb, int colorSpace, bool whitening);
	cv::Mat getSaliencyMap();
	void computeSaliency(double step);

private:
	Mat getAttentionMap(const Mat& bm, int dilation_width_1, bool toNormalize, bool handle_border);
	void whitenFeatMap(const Mat& img, float reg);
	void computeBorderPriorMap(float reg, float marginRatio);

private:
	Mat mSaliencyMap;
	int mAttMapCount;
	Mat mBorderPriorMap;
	Mat mSrc;
	std::vector<cv::Mat> mFeatureMaps;
	int mDilationWidth_1;
	bool mHandleBorder;
	bool mNormalize;
	bool mWhitening;
	int mColorSpace;
};

